using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Main.controls;

namespace Main
{
    public partial class home : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //If the user isn't logged in, redirect them to the home
            //page. 
            if (!this.User.Identity.IsAuthenticated)
            {
                Response.Redirect("default.aspx");
            }
            //So, first, we need to get the recent polls and do that work.
            ShowShortPoll friendsPolls;
            PollCollection polls = new PollCollection();
            polls.FillAllForFriends((Guid)Membership.GetUser().ProviderUserKey, 10);
            foreach (Poll poll in polls)
            {
                friendsPolls = (ShowShortPoll)LoadControl("controls/ShowShortPoll.ascx");
                friendsPolls.CurrentPoll = poll;
                latestPolls.Controls.Add(friendsPolls);
            }
        }
    }
}
